#include<bits/stdc++.h>
using namespace std;

long long n, m, k;
const int N = 1e6;
long long a[N], b[N];
bool check(long long num)
{
	long long ans = k+1;
	for(int i=0; i<=num; i++)
	{
		if(i>n || num-i>m)
			continue;
		ans = min(ans, a[i] + b[num-i]);
	}
	return ans < k;
}

int main()
{
	cin >> n >> m >> k;
	
	for(long long i=1; i<=n; i++)
	{
		cin >> a[i];
		a[i] += a[i-1];		
	}		
	for(long long i=1; i<=m; i++)
	{
		cin >> b[i];
		b[i] += b[i-1];
	}
	
	long long left = 0, right = m + n + 1;
	while(left + 1 < right)
	{
		long long mid = left + (right - left ) / 2;
		if(check(mid))
		{
			left = mid;
		}
		else
		{
			right = mid;
		}
	}
	cout << left << endl;
	return 0;
}